﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Xml.Serialization;

namespace ModelXML
{
    [Serializable]
    public class Cena
    {

        public Cena()
        {
        }

        public List<Modelo> Modelos = new List<Modelo>();
        public List<Helper> Helpers = new List<Helper>();
        public List<Camera> Cameras = new List<Camera>();
        public String Nome;

        public static void SaveXmlContent(Cena obj, String Path)
        {
            FileStream saveFile = File.Open(Path, FileMode.Create);
            XmlSerializer xmlSerializer = new XmlSerializer(typeof(Cena));
            xmlSerializer.Serialize(saveFile, obj);
            saveFile.Flush();
            saveFile.Close();
        }
        
        public static Cena LoadXmlContent(String name)
        {
            if (File.Exists(name))
            {

                FileStream saveFile = File.Open(name, FileMode.Open);
                XmlSerializer xmlSerializer = new XmlSerializer(typeof(Cena));
                Object obj = xmlSerializer.Deserialize(saveFile);
                saveFile.Close();
                return obj as Cena;
            }
            else
            {
                throw new Exception("Arquivo nao encontrado");
            }
        }


    }
}
